﻿using LM.Negocio.Objetos;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace LM.Repositorios.Maps
{
    class ClienteMap : EntityTypeConfiguration<Cliente>
    {
        public ClienteMap()
        {           
            
            this.Property(t => t.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity).HasColumnName("Id");                              


            // Properties
            this.Property(t => t.Nome)
                .IsRequired()
                .HasMaxLength(250);

            this.HasKey(m => m.Codigo);

            this.ToTable("CLIENTE");

            this.Property(t => t.Cpf)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Cnh)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Cliente");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Nome).HasColumnName("Nome");
            this.Property(t => t.Cpf).HasColumnName("Cpf");
            this.Property(t => t.Cnh).HasColumnName("Cnh");
            this.Property(t => t.TipoDoCliente).HasColumnName("TipoDoCliente");
            this.Property(t => t.Codigo).HasColumnName("Codigo");
        }
    }
}
